Inside Macintosh: QuickTime

Previous | Chapter Top | Chapter Contents | Next

Editing Movies

The Movie Toolbox provides a set of high-level functions that allow you to edit movies. This section describes these high-level editing functions. These functions work with a movie's current selection. The current selection is defined by a starting time and a duration.

The Movie Toolbox also provides functions that allow you to edit movie segments. Those functions are described in "Low-Level Movie-Editing Functions," .

The movies created by these functions contain references to the data in the source movie. Because the new movies contain references and not data, they are small and easily moved to and from the scrap. If you delete the movie that contains the data, the data references in the new movies are no longer valid and the new movies cannot be played. Therefore, before you delete the original movie, you should call the FlattenMovie function (described on FlattenMovie ) for each of the new movies. This function copies the data into each of the new movies, eliminating the data references.

Note that the Movie Toolbox does not always copy empty tracks from the source movie to the movies that are created by these functions. Specifically, the Movie Toolbox preserves the empty tracks until you paste or add the selection into the destination movie. At that time, the Movie Toolbox removes the empty tracks from the selection. In addition, if a track in the source movie has trailing empty space, the Movie Toolbox removes that empty space from the track when it is copied into the new movie. Therefore, if you want to add a segment beyond the end of a movie, you insert the space when you insert the new segment using the InsertMovieSegment function (described on InsertMovieSegment ).

The Movie Toolbox allows you to paste different data types into a movie. For example, QuickDraw pictures and standard sound data can be pasted directly into a movie. If you are using the movie controller component, you do not need to use these functions to paste different data types into a movie. (For details on the movie controller component, see Inside Macintosh: QuickTime Components .) If you are calling the Movie Toolbox directly to do editing, you should use the functions described in this section.

To get and change a movie's current selection, your application can call the GetMovieSelection and SetMovieSelection functions.

Your application can work with a movie's current selection by calling the CutMovieSelection , CopyMovieSelection , PasteMovieSelection , ClearMovieSelection , and AddMovieSelection functions.

The PutMovieOnScrap and NewMovieFromScrap functions enable your application to work with movies that are on the scrap.

The IsScrapMovie function examines the system scrap to determine whether it can translate any of the data into a movie. The PasteHandleIntoMovie takes the contents of a specified handle, together with its type, and pastes it into a movie. PutMovieIntoTypedHandle takes a movie (or a single track from within a movie) and converts it into a handle.

PutMovieOnScrap

The PutMovieOnScrap function allows your application to place a movie onto the scrap.

pascal OSErr PutMovieOnScrap (Movie theMovie,
                                         long movieScrapFlags);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
movieScrapFlags
Flags that control the operation. The following flags are available (set unused flags to 0):
movieScrapDontZeroScrap
Controls whether the Movie Toolbox clears the scrap before putting the movie on the scrap. If you set this flag to 1, the Movie Toolbox does not clear the scrap before placing your movie onto this scrap, thus adding your movie to the previous contents of the scrap. If you set this flag to 0, the function clears the scrap, then places your movie on the scrap.
movieScrapOnlyPutMovie
Controls whether the Movie Toolbox places other items on the scrap along with your movie. If you set this flag to 1, the Movie Toolbox only places your movie on the scrap. If you set this flag to 0, the Movie Toolbox places an image from the current movie time (including but not limited to a PICT) on the scrap along with your movie. The picture is intended for use by applications that cannot work with movies.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

Image Compression Manager errors Memory Manager errors

NewMovieFromScrap

The NewMovieFromScrap function allows your application to create a movie from the contents of the scrap, if this is possible. If there is no movie data on the scrap, the Movie Toolbox does not create a new movie.

pascal Movie NewMovieFromScrap (long newMovieFlags);
newMovieFlags
Controls the operation of the NewMovieFromScrap function. The following flags are available (set unused flags to 0):
newMovieActive
Controls whether the new movie is active. Set this flag to 1 to make the new movie active. A movie that does not have any tracks can still be active. When the Movie Toolbox tries to play the movie, no images are displayed, because there is no movie data. Unless you set this flag, you should call the SetMovieActive function (described on SetMovieActive ) to play a movie.
newMovieDontResolveDataRefs
Controls how completely the Movie Toolbox resolves data references in the movie resource. If you set this flag to 0, the toolbox tries to completely resolve all data references in the resource. This may involve searching for files on remote volumes. If you set this flag to 1, the Movie Toolbox only looks in the specified file.
If the Movie Toolbox cannot completely resolve all the data references, it still returns a valid movie identifier. In this case, the Movie Toolbox also sets the current error value to couldNotResolveDataRef .
newMovieDontAskUnresolvedDataRefs
Controls whether the Movie Toolbox asks the user to locate files. If you set this flag to 0, the Movie Toolbox asks the user to locate files that it cannot find on available volumes. If the Movie Toolbox cannot locate a file even with the user's help, the function returns a valid movie identifier and sets the current error value to couldNotResolveDataRef .
newMovieDontAutoAlternate
Controls whether the Movie Toolbox automatically selects enabled tracks from alternate track groups. If you set this flag to 1, the Movie Toolbox does not automatically select tracks for the movie--you must enable tracks yourself.

DESCRIPTION

The NewMovieFromScrap function returns the new movie's identifier. If the function cannot load the movie, the returned identifier is set to nil .

ERROR CODES

couldNotResolveDataRef

-2000

Cannot use this data reference

cantFindHandler

-2003

Cannot locate a handler

cantOpenHandler

-2004

Cannot open a handler

invalidMedia

-2008

This media is corrupted or invalid

File Manager errors Memory Manager errors

SetMovieSelection

The SetMovieSelection function sets a movie's current selection.

pascal void SetMovieSelection (Movie theMovie,
                                          TimeValue selectionTime,
                                          TimeValue selectionDuration);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
selectionTime
Contains a time value specifying the starting point of the current selection.
selectionDuration
Contains a time value that specifies the duration of the current selection.

DESCRIPTION

If you set the selectionDuration parameter to a value greater than the movie's duration, SetMovieSelection automatically adjusts the duration of the selection to correspond to the difference between the value specified in the selectionTime parameter and the end of the movie.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

invalidTime

-2015

This time value is invalid

SEE ALSO

You can use the GetMovieSelection function, described in the next section, to obtain information about a movie's current selection.

GetMovieSelection

The GetMovieSelection function returns information about a movie's current selection.

pascal void GetMovieSelection (Movie theMovie,
                                          TimeValue *selectionTime,
                                          TimeValue *selectionDuration);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
selectionTime
Contains a pointer to a time value. The GetMovieSelection function places the starting time of the current selection into the field referred to by this parameter. Set this parameter to nil if you do not want this information.
selectionDuration
Contains a pointer to a time value. The GetMovieSelection function places the duration of the current selection into the field referred to by this parameter. Set this parameter to nil if you do not want this information.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SEE ALSO

Your application can set the current selection by calling the SetMovieSelection function, which is described in the previous section.

CutMovieSelection

The CutMovieSelection function creates a new movie that contains the original movie's current selection. This function then removes the current selection from the original movie. After the current selection has been removed from the original movie, the duration of the current selection is 0. The starting time of the current selection is not affected.

pascal Movie CutMovieSelection (Movie theMovie);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

DESCRIPTION

The CutMovieSelection function returns a movie identifier. If the function could not create the new movie, it sets this returned identifier to nil .

Your application must dispose of the new movie once you are done with it. You can use the DisposeMovie function (described on DisposeMovie ) to dispose of the new movie.

If you have assigned a progress function to the source movie, the Movie Toolbox calls that progress function during long cut operations. (For details on progress functions, see "Progress Functions," .)

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

progressProcAborted

-2019

Your progress function returned an error

Memory Manager errors

CopyMovieSelection

The CopyMovieSelection function creates a new movie that contains the original movie's current selection. This function does not change the original movie or the current selection.

pascal Movie CopyMovieSelection (Movie theMovie);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

DESCRIPTION

The CopyMovieSelection function returns a movie identifier. If the function could not create the new movie, it sets this returned identifier to nil .

Your application must dispose of the new movie once you are done with it. You can use the DisposeMovie function (described on DisposeMovie ) to dispose of the new movie.

If you have assigned a progress function to the source movie, the Movie Toolbox calls that progress function during long copy operations. (For details on progress functions, see "Progress Functions," .)

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

progressProcAborted

-2019

Your progress function returned an error

Memory Manager errors

PasteMovieSelection

The PasteMovieSelection function places the tracks from one movie into another movie.

pascal void PasteMovieSelection (Movie theMovie, Movie src);
theMovie
Specifies the destination movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
src
Specifies the source movie for this operation. The PasteMovieSelection function places the tracks from this movie in the destination movie.

DESCRIPTION

All of the tracks from the source movie are placed in the destination movie. If the duration of the destination movie's current selection is 0, the source movie is inserted at the starting time of the current selection. If the current selection duration is nonzero, the function clears the current selection and then inserts the tracks from the source movie. After the paste operation, the current selection time is unchanged, and the selection duration is set to the source movie's duration.

Whenever possible, the Movie Toolbox uses existing tracks to store the data to be pasted. Before adding a track to the destination movie, the toolbox looks in the destination movie for tracks that have the same characteristics as the tracks in the source movie. The toolbox considers the following characteristics when searching for an appropriate track:

If the Movie Toolbox cannot find an appropriate track in the destination movie, it creates a track with the proper characteristics.

The Movie Toolbox removes any empty tracks from the destination movie after the paste operation.

If you have assigned a progress function to the destination movie, the Movie Toolbox calls that progress function during long paste operations. (For details on progress functions, see "Progress Functions," .)

SPECIAL CONSIDERATIONS

The entire source movie is used regardless of the selection in the source movie.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

progressProcAborted

-2019

Your progress function returned an error

Memory Manager errors

SEE ALSO

If you want to insert only a part of the source movie, use the InsertMovieSegment function, which is described on InsertMovieSegment .

AddMovieSelection

The AddMovieSelection function adds one or more tracks to a movie. This function scales the source movie so that it fits into the destination selection. If the current selection in the destination movie has a 0 duration, the Movie Toolbox adds the segment at the beginning of the current selection.

pascal void AddMovieSelection (Movie theMovie, Movie src);
theMovie
Specifies the destination movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
src
Specifies the source movie for this operation. The AddMovieSelection function adds the tracks from this movie to the destination movie. The function adds these tracks at the time specified by the current selection in the destination movie.

DESCRIPTION

The AddMovieSelection function is similar to PasteMovieSelection , which is described in the previous section. However, the PasteMovieSelection function inserts empty space into a movie's existing tracks and then adds the new track data. The AddMovieSelection function does not insert empty space into the existing tracks. This function simply adds the tracks in parallel from the source movie to the destination movie. This can be useful for adding a track to an existing movie, such as adding sound to a silent movie.

The Movie Toolbox removes any empty tracks from the destination movie after the add operation.

If you have assigned a progress function to the destination movie, the Movie Toolbox calls that progress function during long add operations. (For details, see "Progress Functions," .)

The entire source movie is used regardless of the selection in the source movie.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

progressProcAborted

-2019

Your progress function returned an error

Memory Manager errors

ClearMovieSelection

The ClearMovieSelection function removes the segment of the movie that is defined by the current selection.

pascal void ClearMovieSelection (Movie theMovie);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

DESCRIPTION

After removing the segment, the Movie Toolbox sets the duration of the movie's current selection to 0 and the selection time remains unchanged. This function removes empty tracks from the resulting movie.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invali d

IsScrapMovie

The IsScrapMovie function looks on the system scrap to find out if it can translate any of the data into a movie.

pascal Component IsScrapMovie (Track targetTrack);
targetTrack
Specifies the location of the potential target movie for the data on the system scrap.

DESCRIPTION

If IsScrapMovie finds an appropriate type, it returns a movie import component that can translate the scrap. Otherwise, it returns 0. For details on movie import components, see Inside Macintosh: QuickTime Components .

PasteHandleIntoMovie

The PasteHandleIntoMovie function takes the contents of a specified handle, together with its type, and pastes it into a specified movie.

pascal OSErr PasteHandleIntoMovie (Handle h, OSType handleType,
                                          Movie theMovie, long flags,
                                          ComponentInstance userComp);
h
Specifies the handle to be pasted into the movie indicated by the handleType parameter.
handleType
theMovie
Specifies the destination movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
flags
Specifies a constant that further refines conditions of the paste operation.
pasteInParallel
Changes the function so that it takes the contents of the specified handle along with its type and adds (rather than inserts) it to the specified movie in an operation analogous to that of the AddMovieSelection function. This operation does not affect the duration of existing tracks. It does not necessarily create a new track; rather, it uses a piece of an existing track, if possible.
userComp
Specifies the component or an instance of the component that is to perform the conversion of the data into a QuickTime movie. If you want a particular movie import component to perform the conversion, you may pass the component or an instance of that component. Otherwise set this parameter to 0 to allow the Movie Toolbox to determine the appropriate component. If you pass in a component instance, it will be used by PasteHandleIntoMovie . This allows you to communicate directly with the component before using this function to establish any conversion parameters. If you pass in a component ID, an instance is created and closed within this function.

DESCRIPTION

If the handle is set to 0, PasteHandleIntoMovie searches the scrap for a field of the type handleType . If both the h parameter and the handleType parameter are nil , PasteHandleIntoMovie uses the first available data from the scrap.

If you are just pasting in data from the scrap, it is best to allow PasteHandleIntoMovie to retrieve the data from the scrap, rather than doing it yourself. In this way, the function is able to obtain supplemental data from the scrap, if necessary (for example, 'styl' resources for 'TEXT' ).

PasteHandleIntoMovie pastes into the current selection according to the following rules:

PutMovieIntoTypedHandle

The PutMovieIntoTypedHandle function takes a movie (or a single track from within that movie) and converts it into a handle of a specified type.

pascal OSErr PutMovieIntoTypedHandle (Movie theMovie,
                                         Track targetTrack,
                                         OSType handleType,
                                         Handle publicMovie,
                                         TimeValue start,
                                         TimeValue dur,
                                         long flags,
                                         ComponentInstance userComp);
theMovie
Specifies the movie to convert.
targetTrack
Specifies the track to convert.
handleType
Indicates the type of the new data.
publicMovie
Contains the actual handle in which to place the new data.
start
Specifies the start time of the segment of the movie or track to be converted.
dur
Specifies the duration of the segment of the movie or track to be converted.
flags
Indicates condition of the conversion. Set this parameter to 0.
userComp
Indicates a component or component instance of the movie export component you want to perform the conversion. Otherwise, set this parameter to 0 for the Movie Toolbox to choose the appropriate component. If you pass in a component instance, it will be used by PutMovieIntoTypedHandle . This allows you to communicate directly with the component before using this function to establish any conversion parameters. If you pass in a component ID, an instance is created and closed within this function. For details on movie export components, see Inside Macintosh: QuickTime Components .

© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next